{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "065c17f1-17c2-473e-acfd-efeef66ee183",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "from perspective.widget import PerspectiveWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e22af644-b8b3-470b-b80f-9d78b492edc5",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.read_parquet(\"new_share.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "59370c2c-5926-4c6d-934e-1ca88389fc5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = pl.read_parquet(\"stock_basic.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4ec5afa2-85c1-47c4-bf3c-49667fd8f17d",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1=d1.with_columns(\n",
    "    ipo_date = pl.col.ipo_date.str.to_date(\"%Y%m%d\"),\n",
    "    issue_date = pl.col.issue_date.str.to_date(\"%Y%m%d\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3f747950-57e2-427a-87cf-a8ddc06b86aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2=d2.with_columns(\n",
    "    list_date = pl.col.list_date.str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cd85b162-c2cb-4cfd-9a3d-7fc4f3e9ed74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3ad8b39584c748acaebd03f04d579049",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7058380a-42b8-4d9b-8420-f4f52325a41c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "851c9dcc1e65402ca83db655e92e5beb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'symbol', 'name', 'area', 'industry', 'fullname',…"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "213e56d2-ed8e-42d0-9f19-4489c0435a6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2_000, 28)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>ts_code</th><th>sub_code</th><th>name</th><th>ipo_date</th><th>issue_date</th><th>amount</th><th>market_amount</th><th>price</th><th>pe</th><th>limit_amount</th><th>funds</th><th>ballot</th><th>symbol</th><th>name_right</th><th>area</th><th>industry</th><th>fullname</th><th>enname</th><th>cnspell</th><th>market</th><th>exchange</th><th>curr_type</th><th>list_status</th><th>list_date</th><th>delist_date</th><th>is_hs</th><th>act_name</th><th>act_ent_type</th></tr><tr><td>str</td><td>str</td><td>str</td><td>date</td><td>date</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>date</td><td>null</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;603014.SH&quot;</td><td>&quot;732014&quot;</td><td>&quot;威高血净&quot;</td><td>2025-05-08</td><td>null</td><td>4114.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>1.1</td><td>0.0</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;301595.SZ&quot;</td><td>&quot;301595&quot;</td><td>&quot;太力科技&quot;</td><td>2025-05-08</td><td>null</td><td>2707.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.65</td><td>0.0</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;688755.SH&quot;</td><td>&quot;787755&quot;</td><td>&quot;汉邦科技&quot;</td><td>2025-05-07</td><td>null</td><td>2200.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.5</td><td>0.0</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;301636.SZ&quot;</td><td>&quot;301636&quot;</td><td>&quot;泽润新能&quot;</td><td>2025-04-28</td><td>null</td><td>1597.0</td><td>774.0</td><td>33.06</td><td>17.57</td><td>0.45</td><td>5.279</td><td>0.02</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;920068.BJ&quot;</td><td>&quot;920068&quot;</td><td>&quot;天工股份&quot;</td><td>2025-04-28</td><td>null</td><td>6000.0</td><td>4200.0</td><td>3.94</td><td>14.98</td><td>255.0</td><td>2.364</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;300777.SZ&quot;</td><td>&quot;300777&quot;</td><td>&quot;中简科技&quot;</td><td>2019-05-06</td><td>2019-05-16</td><td>4001.0</td><td>3601.0</td><td>6.06</td><td>22.98</td><td>1.1</td><td>2.425</td><td>0.04</td><td>&quot;300777&quot;</td><td>&quot;中简科技&quot;</td><td>&quot;江苏&quot;</td><td>&quot;化纤&quot;</td><td>&quot;中简科技股份有限公司&quot;</td><td>&quot;Sinofibers Technology Co.,Ltd.&quot;</td><td>&quot;zjkj&quot;</td><td>&quot;创业板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-16</td><td>null</td><td>&quot;S&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;603267.SH&quot;</td><td>&quot;732267&quot;</td><td>&quot;鸿远电子&quot;</td><td>2019-04-30</td><td>2019-05-15</td><td>4134.0</td><td>3721.0</td><td>20.24</td><td>16.5</td><td>1.6</td><td>8.367</td><td>0.03</td><td>&quot;603267&quot;</td><td>&quot;鸿远电子&quot;</td><td>&quot;北京&quot;</td><td>&quot;元器件&quot;</td><td>&quot;北京元六鸿远电子科技股份有限公司&quot;</td><td>&quot;Beijing Yuanliu Hongyuan Elect…</td><td>&quot;hydz&quot;</td><td>&quot;主板&quot;</td><td>&quot;SSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-15</td><td>null</td><td>&quot;H&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;600989.SH&quot;</td><td>&quot;730989&quot;</td><td>&quot;宝丰能源&quot;</td><td>2019-04-30</td><td>2019-05-16</td><td>73336.0</td><td>66002.0</td><td>11.12</td><td>22.07</td><td>22.0</td><td>81.55</td><td>0.25</td><td>&quot;600989&quot;</td><td>&quot;宝丰能源&quot;</td><td>&quot;宁夏&quot;</td><td>&quot;化工原料&quot;</td><td>&quot;宁夏宝丰能源集团股份有限公司&quot;</td><td>&quot;Ningxia Baofeng Energy Group C…</td><td>&quot;bfny&quot;</td><td>&quot;主板&quot;</td><td>&quot;SSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-16</td><td>null</td><td>&quot;H&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;300778.SZ&quot;</td><td>&quot;300778&quot;</td><td>&quot;新城市&quot;</td><td>2019-04-25</td><td>2019-05-10</td><td>2000.0</td><td>2000.0</td><td>27.33</td><td>22.99</td><td>2.0</td><td>5.466</td><td>0.02</td><td>&quot;300778&quot;</td><td>&quot;新城市&quot;</td><td>&quot;深圳&quot;</td><td>&quot;建筑工程&quot;</td><td>&quot;深圳市新城市规划建筑设计股份有限公司&quot;</td><td>&quot;Shenzhen New Land Tool Plannin…</td><td>&quot;xcs&quot;</td><td>&quot;创业板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-10</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;002953.SZ&quot;</td><td>&quot;002953&quot;</td><td>&quot;日丰股份&quot;</td><td>2019-04-24</td><td>2019-05-09</td><td>4302.0</td><td>3872.0</td><td>10.52</td><td>16.34</td><td>1.7</td><td>4.526</td><td>0.03</td><td>&quot;002953&quot;</td><td>&quot;日丰股份&quot;</td><td>&quot;广东&quot;</td><td>&quot;电气设备&quot;</td><td>&quot;广东日丰电缆股份有限公司&quot;</td><td>&quot;Guangdong Rifeng Electric Cabl…</td><td>&quot;rfgf&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-09</td><td>null</td><td>&quot;N&quot;</td><td>&quot;冯就景&quot;</td><td>&quot;民营企业&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2_000, 28)\n",
       "┌─────────┬─────────┬─────────┬─────────┬───┬────────┬───────┬────────┬────────┐\n",
       "│ ts_code ┆ sub_cod ┆ name    ┆ ipo_dat ┆ … ┆ delist ┆ is_hs ┆ act_na ┆ act_en │\n",
       "│ ---     ┆ e       ┆ ---     ┆ e       ┆   ┆ _date  ┆ ---   ┆ me     ┆ t_type │\n",
       "│ str     ┆ ---     ┆ str     ┆ ---     ┆   ┆ ---    ┆ str   ┆ ---    ┆ ---    │\n",
       "│         ┆ str     ┆         ┆ date    ┆   ┆ null   ┆       ┆ str    ┆ str    │\n",
       "╞═════════╪═════════╪═════════╪═════════╪═══╪════════╪═══════╪════════╪════════╡\n",
       "│ 603014. ┆ 732014  ┆ 威高血  ┆ 2025-05 ┆ … ┆ null   ┆ null  ┆ null   ┆ null   │\n",
       "│ SH      ┆         ┆ 净      ┆ -08     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 301595. ┆ 301595  ┆ 太力科  ┆ 2025-05 ┆ … ┆ null   ┆ null  ┆ null   ┆ null   │\n",
       "│ SZ      ┆         ┆ 技      ┆ -08     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 688755. ┆ 787755  ┆ 汉邦科  ┆ 2025-05 ┆ … ┆ null   ┆ null  ┆ null   ┆ null   │\n",
       "│ SH      ┆         ┆ 技      ┆ -07     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 301636. ┆ 301636  ┆ 泽润新  ┆ 2025-04 ┆ … ┆ null   ┆ null  ┆ null   ┆ null   │\n",
       "│ SZ      ┆         ┆ 能      ┆ -28     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 920068. ┆ 920068  ┆ 天工股  ┆ 2025-04 ┆ … ┆ null   ┆ null  ┆ null   ┆ null   │\n",
       "│ BJ      ┆         ┆ 份      ┆ -28     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …       ┆ … ┆ …      ┆ …     ┆ …      ┆ …      │\n",
       "│ 300777. ┆ 300777  ┆ 中简科  ┆ 2019-05 ┆ … ┆ null   ┆ S     ┆ null   ┆ null   │\n",
       "│ SZ      ┆         ┆ 技      ┆ -06     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 603267. ┆ 732267  ┆ 鸿远电  ┆ 2019-04 ┆ … ┆ null   ┆ H     ┆ null   ┆ null   │\n",
       "│ SH      ┆         ┆ 子      ┆ -30     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 600989. ┆ 730989  ┆ 宝丰能  ┆ 2019-04 ┆ … ┆ null   ┆ H     ┆ null   ┆ null   │\n",
       "│ SH      ┆         ┆ 源      ┆ -30     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 300778. ┆ 300778  ┆ 新城市  ┆ 2019-04 ┆ … ┆ null   ┆ N     ┆ null   ┆ null   │\n",
       "│ SZ      ┆         ┆         ┆ -25     ┆   ┆        ┆       ┆        ┆        │\n",
       "│ 002953. ┆ 002953  ┆ 日丰股  ┆ 2019-04 ┆ … ┆ null   ┆ N     ┆ 冯就景 ┆ 民营企 │\n",
       "│ SZ      ┆         ┆ 份      ┆ -24     ┆   ┆        ┆       ┆        ┆ 业     │\n",
       "└─────────┴─────────┴─────────┴─────────┴───┴────────┴───────┴────────┴────────┘"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=d1.join(d2,on=\"ts_code\",how =\"left\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "351721de-b38e-492a-94fc-12fc2635ffc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c01e452f8f7240a29e3c52b8c639be0d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da753988-6a0d-4e9e-b3a4-1b01a51f4bec",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
